<#-- @ftlvariable name="layout" type="com.fable.sp.core.domain.Layout" -->
<@ui.html>
<div class="container">
    <form class="form-horizontal" action="<@spring.url relativeUrl='/sp/layoutControl'/>" method="post">
        <div class="form-group">
            <input type="hidden" name="containerId" value="${containerId}">
            <#assign copyExt = copy?string("_副本","")/>
            <#if layout??>
                <#if copy>
                    <input type="hidden" name="copyId" value="${layout.id}">
                    <#else >
                    <input type="hidden" name="id" value="${layout.id}">
                </#if>
            </#if>
            <label for="inputName" class="col-xs-2 control-label">名称</label>
            <#assign layoutName = layout?has_content?string(layout.name+copyExt,"")/>
            <div class="col-xs-10">
                <input type="text" class="form-control validate[required,maxSize[100]]" id="inputName"
                       placeholder="请输入名称" value="${layoutName}"
                       name="name">
            </div>
        </div>
        <div class="form-group">
            <label for="inputTextarea" class="col-xs-2 control-label">描述</label>
            <div class="col-xs-10">
                <#assign layoutInfo = layout?has_content?string(layout.info+copyExt,"")/>
                <textarea class="form-control validate[required,maxSize[100]]" rows="5" placeholder="请输入描述"
                          name="info">${layoutInfo}</textarea>
            </div>
        </div>
    </form>
</div>
<script>
    function onSubmit(dg) {
        if ($("form").validationEngine('validate')) {
            var jumpTo = "";
            $.ajax({
                async: false,
                url: "<@spring.url relativeUrl='/sp/layoutControl'/>",
                type: "post",
                data: $("form").serialize(),
                success: function (res) {
                    jumpTo = "<@spring.url relativeUrl='/sp/layoutControl'/>?layoutId=" + res.id;
                }
            });
            return ['jumpTo', jumpTo];
        }
    }

    $(function () {
        $('form').validationEngine('attach', {
            promptPosition: 'bottomLeft',
            scroll: false
        });
    });
</script>
</@ui.html>